package com.lyj.sc.aliyuntianchi.test20220714;

/**
 * @Author: liyangjing
 * @Date: 2022/07/13/21:02
 * @Description:
 */
public class test1 {
    public int removeDuplicates(int[] nums) {
        //双指针法
        int n = nums.length;
        if(n==0){
            return 0;
        }
        int fast=1;
        int slow=1;
        while(fast<n){
            if(nums[fast]!=nums[fast-1]){
                nums[slow]=nums[fast];
                slow++;
            }
            fast++;
        }
        return nums.length;
    }
}
